/*
 * @Author: yao
 * @Date: 2024-11-15 17:12:58
 * @LastEditTime: 2024-11-15 18:48:28
 * @LastEditors: yao
 * @Description:
 * @FilePath: \jdev-web\src\utils\utils.ts
 */
import config from "@/config/index";
import Storage from "./storage";

export const setToken = (token: string) => {
  Storage.setCookie(config.TOKEN_KEY, token);
};

export const getToken = () => {
  const token = Storage.getCookie(config.TOKEN_KEY);
  if (token) {
    return token;
  } else {
    return false;
  }
};
export const prefixProxy = (prefix: string = "") => {
  return {
    get: function (target, prop, receiver) {
      const value = Reflect.get(target, prop, receiver);
      if (typeof value === "string" || typeof value === "number") {
        return prefix + value;
      }
      return value;
    },
  };
};
